package com.ljtxxhwj.myblob.service.impl;

import com.ljtxxhwj.myblob.entity.*;
import com.ljtxxhwj.myblob.mapper.ArticleKindMapper;
import com.ljtxxhwj.myblob.mapper.ArticleTagMapper;
import com.ljtxxhwj.myblob.service.ArticleKindService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author ljtxxhwj
 * @since 2024-07-19
 */
@Service
public class ArticleKindServiceImpl implements ArticleKindService {
    @Autowired
    private ArticleKindMapper articleKindMapper;

    @Override
    public List<ArticleKind> findAllArticleKind() {
        List<ArticleKind> articleKindList=articleKindMapper.selectByExample(null);

        return articleKindList;
    }

    @Override
    public List<ArticleKind> findByKindName(String kindName) {
        ArticleKindExample example=new ArticleKindExample();
        example.createCriteria().andArticleKindLike("%"+kindName+"%");
        List<ArticleKind> articleKindList= articleKindMapper.selectByExample(example);
        return articleKindList;
    }

    @Override
    public void deleteByArticleKindId(Integer articleKindId) {
        //删除分类
        articleKindMapper.deleteByPrimaryKey(articleKindId);
    }

    @Override
    public void saveKind(ArticleKind articleKind) {
        articleKindMapper.insert(articleKind);
    }

    @Override
    public int deleteBatch(String[] ids) {
        return articleKindMapper.deleteBatch(ids);
    }
}
